package com.gimi.cloud.jimi.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValiStringUtil {

	public static String getPoId(String hotelid, int pmsID) {

		Pattern pattern = Pattern.compile("[0-9]*");
		Matcher isNum = pattern.matcher(hotelid);
		int b = 0;
		int c = 0;
		String k = null;
		String poid = null;
		if (!isNum.matches()) {
			String t = String.format("%04d", pmsID);
			c = Integer.parseInt(t) >> 4;
			poid = hotelid.trim() + String.valueOf(c);

		} else {
			if (hotelid.length() == 1 && Integer.parseInt(hotelid) <= 4 && pmsID==1001 || pmsID==2001) {
				k = String.format("%010d", Integer.parseInt(hotelid));
				String t = String.format("%04d", pmsID);
				b = Integer.parseInt(k) << 3;
				c = Integer.parseInt(t) >> 4;
				poid = String.valueOf(b) + String.valueOf(c);
			} else {
				String t = String.format("%4d", pmsID);
				poid = hotelid + String.valueOf(t);
			}

		}

		return poid;
	}
	
	public static void main(String[] args) {
		String k=ValiStringUtil.getPoId("30002", 6002);
		System.out.println(k);
	}	
}
